package com.ruoyi.project.charge.controller;

import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.project.charge.domin.ChargeInfo;
import com.ruoyi.project.charge.service.IChargeService;
import com.ruoyi.project.charge.vo.ChargeParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;

/**
 * @auther:YU JIANG
 * @date:2021/7/13
 * @time:14:41
 */
@RestController
@RequestMapping("/system/charge")
public class ChargeController extends BaseController {

    @Autowired
    private IChargeService chargeService;

    @GetMapping("/list")
    @PreAuthorize("@ss.hasPermi('charge:charge:query')")
    public AjaxResult queryInfo(ChargeInfo chargeInfo){
        List<ChargeInfo> list = chargeService.queryInfo(chargeInfo.getReg_id());
        return AjaxResult.success(list!= null && list.size() > 0 ? list.get(0) : null);
    }

    //修改支付状态
    @GetMapping("/updateStatus")
    @PreAuthorize("@ss.hasPermi('charge:charge:query')")
    public AjaxResult updateStatus(ChargeParams  params){
        System.out.println("挂号ID："+params.getReg_id()+",支付状态："+params.getPay_status()+",检查项目ID："+ params.getCheck_id() +",药品ID："+params.getDrug_id()+",支付方式："+params.getPayment_method()+",药品数量："+params.getDrug_amount()+",药品名称："+params.getDrug_name()+",药品单价："+params.getDrug_Rx_price()+",药品价格："+params.getDrug_price()+",类型药品："+params.getDrug_type()+",类型项目："+params.getExam_type()+",支付状态："+params.getPay_status()+",项目名称："+params.getExam_name()+",项目编号："+params.getExam_id()+",项目价格："+params.getCase_price());
        int i = chargeService.updatePayStatus(params.getReg_id(),params.getPay_status(),params.getCheck_id(),params.getDrug_id(),params.getTotal_price(),params.getPayment_method(),params.getDrug_amount(),params.getDrug_name(), params.getDrug_Rx_price(),params.getDrug_price(), params.getDrug_type(),params.getExam_type(),params.getExam_name(), params.getExam_id(), params.getCase_price());
        return toAjax(i);
    }


}
